#ifndef CRC32_H_
#define CRC32_H_

#include <string>


class CRC32 {

private:

    // The crc data checksum so far.
    uint32_t m_crc;

    //The fast CRC table. Computed once when the CRC32 class is loaded.
    static uint32_t* m_crc_table;

    // Make the table for a fast CRC.
    static uint32_t* make_crc_table();

public:
    CRC32();

    static void init();

    // Returns the CRC32 data checksum computed so far.
    uint32_t getValue ();

    //Resets the CRC32 data checksum as if no update was ever called.
    void reset ();

    //add an int
    void update(uint32_t n);

    // Adds the byte array to the data checksum.
    void update (const char* buf, uint32_t off, uint32_t len);

    // Adds the complete byte array to the data checksum.
    void update (const std::string& buf);

private:

    uint32_t crc32c_sb8_64_bit(const char*  p_buf, uint32_t length);
};

#endif
